package com.ai.wxy.spring.jpa.test.security;

import com.ai.wxy.spring.auth.dto.UserDTO;
import com.ai.wxy.spring.auth.service.IUserRoleService;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;

/**
 * 用户权限
 *
 * @author 石头
 * @Date 2019/10/31
 * @Version 1.0
 **/
@Service
public class UserRoleService implements IUserRoleService {
    @Override
    public UserDTO findByName(String userName) {
        UserDTO userDTO = new UserDTO();
        userDTO.setId(100001L);
        userDTO.setEnabled(true);
        userDTO.setUsername("test-01");
        userDTO.setPassword("abc123");
        userDTO.setAccountNonLocked(true);
        userDTO.setLastPasswordResetDate(Date.from(LocalDate.parse("2019-10-15").atStartOfDay(ZoneId.systemDefault()).toInstant()));
        return userDTO;
    }

    @Override
    public List<String> findUserRoles(Long userId) {
//        return Arrays.asList("ROLE_ADMIN","ROLE_USER");
        return Arrays.asList("ROLE_P_USER");
    }
}
